<template>
  <h1>猜数字练习</h1>
  <input type="text" placeholder="请输入1-100之间的数字" v-model="n">
  <button @click="guessNum">猜一猜</button>
  <h4>{{result}}</h4>
</template>

<script setup>
import {ref} from "vue";

let num=parseInt(Math.random()*100+1);
const n=ref('');
const result=ref('');
const guessNum=()=>{
  if(n.value>num){
    result.value='猜大了！';
  }else if(n.value<num){
    result.value='猜小了！';
  }else{
    result.value='猜对了！';
  }
}
</script>

<style scoped>

</style>